package com.xmy.cultivate.listeners;

import com.xmy.cultivate.constants.MqConstants;
import com.xmy.cultivate.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Slf4j
@Component
public class WeCahrPushListener {

    @Autowired
    private TemplateService templateService;


//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = MqConstants.QUEUE_WECHAR_PUSH_Q1, durable = "true"),
//            exchange = @Exchange(name = MqConstants.EXCHANGE_WECHAR_PUSH_FANOUT, type = ExchangeTypes.FANOUT)
//    ))
//    public void wecharPush(String obj) throws IOException {
//        try {
//            templateService.send(obj);
//            //System.out.println("wecharPush成功:"+obj);
//        }catch (Exception e) {
//            System.out.println("wecharPush:"+e.getMessage());
//        }
//
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = MqConstants.QUEUE_WECHAR_SIGIN_PUSH_Q1, durable = "true"),
//            exchange = @Exchange(name = MqConstants.EXCHANGE_WECHAR_SIGIN_PUSH_FANOUT, type = ExchangeTypes.FANOUT)
//    ))
//    public void wecharSiginPush(String obj) throws IOException {
//        try {
//            templateService.send(obj);
//            //System.out.println("wecharPush成功:"+obj);
//        }catch (Exception e) {
//            System.out.println("wecharPush:"+e.getMessage());
//        }
//
//    }

}
